// g++ -o virtual virtual.cc -std=c++11
#include <iostream>
using namespace std;
class Base {
 public:
  void func1() { cout << "Base::func1" << endl; }
  virtual void vfunc1() { cout << "Base::vfunc1" << endl; }
  virtual void vfunc2() { cout << "Base::vfunc2" << endl; }

 protected:
  int base_data_ = 10;
};
class Derived : public Base {
 public:
  void vfunc1() { cout << "Derived::vfunc1" << endl; }

 private:
};
void Test() {
  Base* ptr = new Derived;
  ptr->func1();
  ptr->vfunc1();  // ((ptr->__vptr)[0])(ptr);
  ptr->vfunc2();

  delete ptr;
}
int main() {
  Test();
  return 0;
}